val_list_file='/home/nihao/data/MonoDETR/data/KITTIDataset/ImageSets/val.txt'
label_from='/home/nihao/data/down-nuScenes-full/nusc_kitti/val/label_2'
label_to='/home/nihao/data/MonoDETR/outputs/monodetr/outputs/data'

import os
import shutil
import random
import numpy as np

vals=[]

for filename in os.listdir(label_from):
    vals.append((filename).split('.')[0])

for valll in vals:
    val=valll.strip()
    fr=os.path.join(label_from,val+'.txt')
    to=os.path.join(label_to,val+'.txt')
    srcf=open(fr,'r')
    dstf=open(to,'w')
    src=srcf.readlines()
    for l in src:
        if l.startswith('car'):
            data_line=l.strip().split(' ')
            res=data_line[:8]
            str_3d=[float(x)+float(np.random.randn(1))*0.2 for x in data_line[8:-1]]
            a=data_line[-1]
            for att3d in str_3d:
                res.append("{:.2f}".format(att3d))
            res.append(a)
            res.append(str(random.randint(2,8))+'.0')
            dstf.write(' '.join(res)+'\n')
    srcf.close()
    dstf.close()
